package com.zygk.xmpp.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.zygk.library.adapter.BaseListAdapter;
import com.zygk.xmpp.R;
import com.zygk.xmpp.R2;
import com.zygk.xmpp.model.M_Emoji;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 表情适配器
 * created by Djy
 * 2018/7/18 0018 下午 2:20
 */
public class EmojiAdapter extends BaseListAdapter<M_Emoji> {

    public EmojiAdapter(Context context, List<M_Emoji> list) {
        super(context, list);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.xmpp_item_emoji, null, false);
            holder = new ViewHolder(convertView);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        M_Emoji m = getItem(position);
        holder.ivEmoji.setImageResource(m.getResId());

        return convertView;
    }

    static class ViewHolder {
        @BindView(R2.id.iv_emoji)
        ImageView ivEmoji;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}